<%--

  User: 刘军海
  Date: 2014/11/12 15:42
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="st" tagdir="/WEB-INF/tags" %>

<st:page>
    <div id="toolbar">
        <a href="#" id="addStyle" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="addNew(this);">增加请求</a>
            <%--<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="test(this);">测试</a>--%>
    </div>
    <table id="dgRequest" style="width:100%;"
           data-options="view:emptyDataView,fit:true,toolbar:'#toolbar',singleSelect:true">
        <thead data-options="frozen:true">
        <tr>
            <th data-options="field:'desId',formatter:optFormatter">操作</th>
        </tr>
        </thead>
        <thead>
        <tr>
            <th data-options="field:'requestId',width:150">请求ID</th>
            <th data-options="field:'requestName',width:100">请求名称</th>
            <th data-options="field:'functionName',width:70">所属模块</th>
            <th data-options="field:'actionName',width:70">所属操作</th>
            <th data-options="field:'checkFunctionPrivilege',width:80">检测模块权限</th>
            <th data-options="field:'requestType',width:60">请求类型</th>
            <th data-options="field:'responseType',width:60">响应类型</th>
            <th data-options="field:'url',width:230">转发地址</th>

            <th data-options="field:'beanClassName',width:200">Bean类</th>
            <th data-options="field:'beanClassMethodName',width:100,align:'center'">bean方法名</th>

            <th data-options="field:'usedGeneralService',width:80">启用通用模块</th>

            <th data-options="field:'generalAction',width:60">操作方式</th>
            <th data-options="field:'entityPkGenerateKey',width:60">主键key</th>
            <th data-options="field:'entityClassName',width:160">实体类定义</th>
            <th data-options="field:'entityTrigger',width:100">触发器</th>


        </tr>
        </thead>
    </table>
    <script>
        var nodeId = "";
        function init() {
            nodeId = parent.nodeId;
            $("#dgRequest").datagrid({
                url: "/user/sys/qmdManager?act=frequests",
                queryParams: {functionId: nodeId}
            }).datagrid("columnMoving");
        }
        function optFormatter(val, row) {
            var opt = "";
            opt = "<a href='javascript:void(0);' onclick=\"update(this,'" + val + "');\" >修改</a>";
            opt += " <a href='javascript:void(0);' onclick=\"del(this,'" + val + "');\" >删除</a>";
            return opt;
        }
        function addNew(sender) {
            j.open("/user/sys/qmdManager?act=editr&functionId=" + nodeId, "editWin", {title: "增加请求"}, 500, 400);
        }
        function update(sender, rid) {
            j.open("/user/sys/qmdManager?act=editr&requestId=" + rid, "editWin", {title: "修改请求"}, 500, 400);
        }
        function del(sender, rid) {
            if (window.confirm("若删除此请求，前台使用此请求将会无效，请确认此请求当前未使用，确认删除吗？")) {
                Http.post("/user/sys/qmdManager?act=delr", {requestId: rid}, function (data) {
                    alert("删除成功！");
                    $("#dgRequest").datagrid("reload");
                });
            }
        }
        function reload() {
            $("#dgRequest").datagrid("reload");
        }
        function test() {
            var opts = $('#dgRequest').datagrid('getColumnFields');
            for (var i = 0; i < opts.length; i++) {
                var field = $("#dgRequest").datagrid("getColumnOption", opts[i]);
                alert(field.width);
            }
        }
        $(function () {
            window.setTimeout(function () {
                init();
            }, 1);
        });
    </script>
</st:page>